
/**
 * 头部信息控制器
 * @param $scope
 * @param $http
 * @returns
 */
var headCtrl = {
		CurrentUser:{},
		DepartName:{},
		init:function(){
			/**
             * 先校验登陆状态，成功则加载内容
             */
            $.ajax({
                method : 'GET',
                url : "/Portal/Organization/GetCurrentUser",
                success:function(result) {
                    if(result.Success) {
                    	headCtrl.CurrentUser = result.User;
                    	headCtrl.DepartName = result.OUDepartName;
                        var date = new Date();
                        var weatherStr = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
                        $("#head-weather").html(weatherStr);
                        $("#head-userName").html(headCtrl.CurrentUser.Name);

                        for(var i = 0 ;i < result.Functions.length;i++) {
                            if (result.Functions[i].Code == "CRMApp" && result.Functions[i].Children.length > 0 ) {
                                $("#crm")[0].style.display=""
                            }
                            if (result.Functions[i].Code == "knowledgePlatform" && result.Functions[i].Children.length > 0 ) {
                                $("#knowledge")[0].style.display=""
                            }
                        }


                    } else {
                        window.location.href = "/Portal/#/platform/login";
                    }
                }
            });
            //obj.weatherStr = weatherStr;
            //$scope.Head = obj;
		}
}

//headCtrl.init();

//登出
function logout(){
	$.ajax({
		method:'GET',
		url: "/Portal/Index/LoginOut",
		success:function(){
			window.location.href = "/Portal/#/platform/login";
    	},error:function(e1,e2,e3){
    		console.log("111");
    	}
	});
}


(function(T,h,i,n,k,P,a,g,e){g=function(){P=h.createElement(i);a=h.getElementsByTagName(i)[0];P.src=k;P.charset="utf-8";P.async=1;a.parentNode.insertBefore(P,a)};T["ThinkPageWeatherWidgetObject"]=n;T[n]||(T[n]=function(){(T[n].q=T[n].q||[]).push(arguments)});T[n].l=+new Date();if(T.attachEvent){T.attachEvent("onload",g)}else{T.addEventListener("load",g,false)}}(window,document,"script","tpwidget","//widget.seniverse.com/widget/chameleon.js"))
tpwidget("init", {
    "flavor": "slim",
    "location": "WX4FBXXFKE4F",
    "geolocation": "enabled",
    "language": "zh-chs",
    "unit": "c",
    "theme": "chameleon",
    "container": "tp-weather-widget",
    "bubble": "enabled",
    "alarmType": "circle",
    "uid": "UA315FD18A",
    "hash": "9161a771bb96f9b5f406a8ad820633e9"
});
tpwidget("show");

